import React from "react";
import Child from "./Children";

interface ParentState{
    message:string,
    title:string,
}
class Parent extends React.Component<{},ParentState>{
    constructor(props:any){
        super(props)
        this.state={
            message: '我是父组件,需要传入的数据',
            title:''
        }
    }
    handleData = (childData:any) => {
       console.log(childData)
       this.setState({ title:childData })
    };

    render(){
        return(
            <div>
                我是父组件
                <Child message={this.state.message} onData={this.handleData}></Child>
                <h3>{this.state.title}</h3>
            </div>
        )

    }
}
export default Parent;